Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
Creating the Pop-up menu
The
initializeObjectprocedure callscreateBrowsePopupMenuunless the menu has been disabled. This custom procedure creates the menu and its menu items as dynamic 4GL objects.The first thing to examine is why it is necessary to pass in the procedure handle of the browser object as an
INPUTparameter. The call tocreateBrowsePopupMenuininitializeObjectlooks like the following:
The called procedure defines it as an
INPUTparameter to be used later in the code, as shown:
So why can’t
createBrowsePopupMenujust referenceTARGET-PROCEDUREdirectly, as you have seen in many other cases? For the answer, refer back to the discussion and diagrams in Chapter 1, " Writing Super Procedures for Progress Dynamics Objects." There we explained that in order for any internal procedure to refer toTARGET-PROCEDUREsuccessfully, it must itself be runINTARGET-PROCEDURE. In this case, becausecreateBrowsePopupMenuis in the same procedure file as theinitializeObjectprocedure that calls it, theRUNstatement just makes the call directly. For this reason, a reference toTARGET-PROCEDUREwithincreateBrowsePopupMenuevaluates to the handle of the super procedurebrowsercustom.p, not to the browser SmartObject instance itself, and this is not what the code needs. Thus, either theTARGET-PROCEDUREhandle must be passed in as an argument or theRUNstatement must bounce back tobrowsercustom.pby being formulated asRUNcreateBrowsePopupMenuINTARGET-PROCEDURE. Either technique works.The code first creates the menu object itself, as shown:
It then creates each of the following menu items:
Again, see the accompanying procedure file for the complete code.
Next, the procedure attaches the menu to the browse widget handle, which it has retrieved using the
BrowseHandleproperty of the browser object. Just to clarify, theBrowseHandleis the widget handle of the browse control itself. ThehTargetparameter passed in to the procedure is the procedure handle of the browser SmartObject instance, as shown:
Finally, the code defines trigger procedures for the
MENU-DROPevent of the menu itself, theVALUE-CHANGEDevent of theMovable ItemandSortable Item, which control the check marks on those items, and theCHOOSEevent for the Save and Reset options. ThePERSISTENTRUNsyntax is required to associate an internal procedure such aseventMenuItemValueChangedwith a dynamic menu item, as shown:
Note that it is important for the trigger definitions to specify that the event procedure is run
INTARGET-PROCEDURE. BecauseTARGET-PROCEDUREitself is not available here, as noted, they do this using the procedure handlehTargetthat was passed in as a parameter. In this way, the individual trigger procedures can correctly referenceTARGET-PROCEDUREthemselves.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |